﻿@model QuanLyGiaoVuUI.Models.GiangVienClient.TienDoDeTaiViewModel
@{
    Layout = null;
}

<script type="text/javascript" src="@Url.Content("~/Content/js/jsToastMessage/javascript/jquery.toastmessage.js")"></script> 
<div>
    <table class="data display datatable">
        <tr>
            <th class="sorting">STT</th>
            <th class="sorting">Tiêu đề</th>
            <th class="sorting">Hoàn thành</th>
            <th class="sorting">Ngày thêm</th>
            <th class="sorting">Nội dung</th>
            <th class="sorting"></th>
        </tr>     
        @{Guid madetai=Guid.NewGuid();}      
    @if (Model.DanhSachTienDoDT != null)
    {
        var count=0;
        var stt=1;
        foreach (var tienDo in Model.DanhSachTienDoDT)
        {
            madetai = tienDo.MaDeTai;
            <tr class="gradeA @(++count % 2 == 0 ? "even" : "odd")">
                <td class="odd gradeX">@(stt++)</td>
                <td class="odd gradeX">@tienDo.TieuDe</td>
                <td class="odd gradeX"><span>@tienDo.TienDoHoanThanh %</span></td>
                <td class="odd gradeX"><span>@tienDo.NgayBaoCao.ToShortDateString()</span></td>
                <td class="odd gradeX"><span>@Html.Raw(tienDo.NoiDung)</span></td>
                <td class="odd gradeX"><span><a href="#" class="xoatiendodetaidt" rel="@tienDo.MaTienDoDeTai">[X]</a></span></td>
            </tr>
        }
    }
    </table>
    <div><input type="hidden" id="madetai2" value="@madetai" /></div>
</div>
<div>
        <input type="button" value="Thêm" id="themtiendo" />
</div> 

@*<script type="text/javascript" src="/Scripts/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="/Content/js/timetable/jquery.ba-resize.js"></script>
    <script type="text/javascript" src="/Content/js/timetable/bootstrap-tooltip.js"></script>
    <script type="text/javascript" src="/Content/js/timetable/bootstrap-collapse.js"></script>
    <script type="text/javascript" src="/Content/js/timetable/tribal.js"></script>
    <script type="text/javascript" src="/Content/js/timetable/tribal-shared.js"></script>
    <script type="text/javascript" src="/Content/js/timetable/tribal-timetable.js"></script>
    <script type="text/javascript" src="/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-ui.js"></script>*@

<div id="dangKyTienDoDeTaiDialog"></div>

    <script>
        var opt = {
            autoOpen: false,
            modal: true,
            width: 500,
            height: "auto",
            title: "Thêm tiến độ đề tài",
            buttons: {
                "Thêm": function () {
                    $("#btnaddtiendodetai").click();
                },
                "Hủy": function () {
                    $("#dangKyTienDoDeTaiDialog").dialog("close");
                }
            }
        };
        $(document).ready(function () {
            var isSuccess = false;
            $('.xoatiendodetaidt').click(function () {
                var r = confirm("Bạn có muốn xoá tiến độ này?")
                if (r == false) {
                    return;
                }
                var matiendodetai = $(this).attr("rel");
                //alert(madetai);
                if (matiendodetai == null || matiendodetai == "") {
                    return;
                }
                else {
                    var madetai = $("#madetai2").val();
                    //alert(madetai);
                    $.post("/GiangVienClient/DeleteTienDoDeTai", { maTienDoDeTai: matiendodetai }, function (data) {
                        if (data.success == true) {
                            ThongBao(true,"Xóa thành công!");
                            $("#quanlytiendo-main").load("/giangvienclient/tiendodetai/" + madetai);
                            //window.location = "/GiangVienClient/Detai";
                        }
                        else {
                            ThongBao(false,"Thao tác không thành công!");
                        }
                    });
                }
            });
                                      
            

            $('#themtiendo').click(function () {
                //$("#dangKyTienDoDeTaiDialog").dialog({
                //    autoOpen: false, modal: true, width: 500, height: "auto", title: "Thêm tiến độ đề tài",
                //    buttons: {
                //        "Thêm": function () {
                //            $("#btnaddtiendodetai").click();
                //        },
                //        "Hủy": function () {
                //            $("#dangKyTienDoDeTaiDialog").dialog("close");
                //        }
                //    }
                //});

                var madetai = $("#currentID").val();
                $("#dangKyTienDoDeTaiDialog").load("/giangvienclient/addtiendodetai/" + madetai);                
                $("#dangKyTienDoDeTaiDialog").dialog(opt).dialog("open");
            });
            
        });
        function ThongBao(success,message) {
            if (success)
                ToastManager.showSuccessToast(message);
            else {
                ToastManager.showStickyWarningToast(message);
            }
        }
    </script>
